<!--
 * @Author: zxc
 * @Date: 2020-08-24 12:52:42
 * @LastEditTime: 2020-10-31 19:33:46
 * @LastEditors: zxc
 * @Description:
-->
<template>
  <div>
    <input v-model="userName" />
    <input type="password" v-model="password" />
    <button @click="handleSubmit">登录</button>
  </div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
  name: 'login_page',
  data () {
    return {
      userName: '',
      password: ''
    }
  },
  methods: {
    ...mapActions(['login']),
    handleSubmit () {
      this.login({
        userName: this.userName,
        password: this.password
      })
        .then(() => {
          console.log('success!!')
          this.$router.push({
            name: 'Home'
          })
        })
        .catch((error) => {
          console.log(error)
        })
    }
  }
}
</script>
